﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ComicBook.Data.IDataAdapters.Interfaces;
using ComicBook.Data.IDataAdapters.Adapters;
using ComicBook.DataModels;

namespace ComicBook.web.Controllers
{
    public class CharacterController : Controller
    {
        IComicBookAdapter _adapter;
        public CharacterController()
        {
            _adapter = new ComicBookAdapter();
        }
        public CharacterController(IComicBookAdapter adapter)
        {
            _adapter = adapter;
        }
        [HttpGet]
        public ActionResult AddCharacter(int id)
        {
            return View(id);
        }
        [HttpPost]
        public ActionResult AddCharacter(string name, int comicId)
        {
            Character c = new Character();
            c.Name = name;
            c.ComicId = comicId;
            c = _adapter.AddCharacter(c);
            return RedirectToAction("CharacterDetail/" + c.Id);
        }
        public ActionResult CharacterDetail(int id)
        {
            Character c = _adapter.GetCharacter(id);
            return View(c);
        }
	}
}